package com.openatc.agent.service.area;

import com.openatc.agent.model.area.Area;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Classname AreaRepository
 * @Description
 * @Date 2022/9/5 11:21
 * @Created by panleilei
 */
public interface AreaRepository extends JpaRepository<Area,Integer> {
    Area findByName(String name);

    Area findById(Long id);

    @Query(value = "SELECT new Area(a.id,a.name,a.keyintsid,a.optstrategy,a.cycle) from Area a order by a.id")
    List<Area> findAreaSimpleInfo();

    @Transactional
    void deleteById(Long id);
}
